<template>
  <div class="zl-echart-config">
    <div style="height:32px;line-height: 32px;">
      <div class="f-l">图片上传</div>
      <div class="r-cnt f-r">
          <Upload action=""
          :before-upload="handleBeforeUpload"
          :show-upload-list="false">
              <Button icon="ios-cloud-upload-outline">jpg/png/gif/bmp</Button>
          </Upload>
        </div>
    </div>
  </div>
</template>
<script type="text/javascript">
import getData from 'getData'

export default {
  name: 'ZlImg',
  data () {
    return {
    }
  },
  props: {
    echartImgURL:{
        type:Object,
        default:function(){
            return {};
        }
    },
    graphType:{
        type:String
    }
  },
  methods: {
    handleBeforeUpload(file) {
    	let _this = this
      let url = ZLST_BIGDATA_CONFIG_DEV.UPLOAD_SERVER + '/file/upload'
      var formData = new FormData()
      getData.post('fileUploadImg', { file: file, url: url } , { dataType: 'formData' }).then(res => {
        if (res.status === 200 && res.data.code === '000') {
          let imgURLTemp = ZLST_BIGDATA_CONFIG_DEV.ACCESS_SERVER + '/' + res.data.data.group + '/' + res.data.data.path
          this.$set(_this.echartImgURL, 'imgUrl', imgURLTemp)
        }else{
          _this.$Message.error('文件上传失败')
        }
      })
      return false
    }
  }
}
</script>
<style rel="stylesheet/less" lang="less" scoped>
</style>
